package com.gitee.wsl.ext.list


/**
 * @param src1
 * Original list.
 * @param src2
 * Additional items to add.
 * @param <T>
 * Type of content.
 *
 * @return New list with additional items.
</T> */
fun <T> combine(src1: List<T>?, src2: List<T>?): List<T> {
    var src1: List<T>? = src1
    var src2: List<T>? = src2
    if (src1 == null) src1 = emptyList()
    if (src2 == null) src2 = emptyList()

    if (src2.isEmpty()) {
        if (src1.isEmpty()) return emptyList()
        return src1
    }

    val list= ArrayList<T>(src1.size + src2.size)
    list.addAll(src1)
    list.addAll(src2)
    return list
}